package com.gj.server.controller;

import com.gj.model.register.DynamicThreadPoolRegisterWrapper;
import com.gj.server.service.ConfigService;
import com.gj.web.base.Result;
import com.gj.web.base.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConfigController {

    @Autowired
    private ConfigService configService;

    @PostMapping("/updateConfig")
    public Result updateConfig() {
        //服务端要通知客户端，更改参数？
        //不行，http 是单向的
        //只能客户端向服务端发起请求
        //长轮询
        return Results.success();
    }

    @PostMapping("/listen")
    public void longPollingRequest(ServletServerHttpRequest request, ServletServerHttpResponse response) {

    }


    @PostMapping("/config/register")
    public Result registerThreadPoolExecutor(@RequestBody DynamicThreadPoolRegisterWrapper requestParam) {
        configService.register(requestParam);
        return Results.success();
    }
}
